import QtQuick 1.0

Rectangle {
    x: 0
    y: 0
    width: 800
    height: 400

    color: "black"

    Routes {
        id: routes
        anchors.top: parent.top
        anchors.left: parent.left
        height: parent.height-journeyButtons.height
    }

    Legs {
        id: legs
        anchors.top: parent.top
        anchors.bottom: journeyButtons.top
        anchors.left: routes.right
        anchors.right: parent.right
        width: parent.width-routes.width
        routeIndex: routes.routeIndex
    }

    Row {
        id: journeyButtons
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        width: parent.width

        Button {
            id: homeButton
            width: parent.width/2
            height: 66
            enabled: true
            pointSize: 20
            text: "GPS->HOME"
            onClicked: {
                console.log("MAXMAXMAX/clicked")
                var doc = new XMLHttpRequest();
                doc.onreadystatechange = function() {
                    if (doc.readyState == XMLHttpRequest.DONE) {
                        var a = doc.responseText;
                        routes.xml = a;
                        legs.xml = a;
                    }
                }
                //                doc.open("GET", "http://api.reittiopas.fi/hsl/prod/?user=zouba&pass=caf9r3ee&request=route&format=xml&language=en&epsg_in=wgs84&epsg_out=wgs84&from=24.7765,60.2046&to=24.8825483159,60.1618275013&show=5&walkspeed=2&optimize=4");
                doc.open("GET", "routeData.xml");
                doc.send();
            }
        }
        Button {
            id: workButton
            width: parent.width/2
            height: 66
            enabled: true
            pointSize: 20
            text: "GPS->WORK"
            onClicked: {
                enabled=!enabled
            }
        }
    }
}
